<template>
  <div class="skeleton-container">
    <el-card class="skeleton-card">
      <div class="skeleton-table">
        <!-- 表头骨架 -->
        <div class="skeleton-header">
          <div class="skeleton-header-row">
            <div class="skeleton-cell" style="width: 55px;"></div>
            <div class="skeleton-cell" style="width: 60px;"></div>
            <div class="skeleton-cell" style="width: 120px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 100px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 100px;"></div>
            <div class="skeleton-cell" style="width: 200px;"></div>
          </div>
        </div>
        
        <!-- 表体骨架 -->
        <div class="skeleton-body">
          <div v-for="index in rowCount" :key="index" class="skeleton-row">
            <div class="skeleton-cell" style="width: 55px;"></div>
            <div class="skeleton-cell" style="width: 60px;"></div>
            <div class="skeleton-cell" style="width: 120px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;">
              <div class="skeleton-tag"></div>
            </div>
            <div class="skeleton-cell" style="width: 100px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 80px;"></div>
            <div class="skeleton-cell" style="width: 100px;">
              <div class="skeleton-image"></div>
            </div>
            <div class="skeleton-cell" style="width: 200px;">
              <div class="skeleton-action-buttons">
                <div class="skeleton-button"></div>
                <div class="skeleton-button"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 分页骨架 -->
      <div class="skeleton-pagination">
        <div class="skeleton-pagination-content">
          <div class="skeleton-pagination-info"></div>
          <div class="skeleton-pagination-buttons">
            <div v-for="i in 7" :key="i" class="skeleton-pagination-button"></div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { defineProps } from 'vue'

const props = defineProps({
  rowCount: {
    type: Number,
    default: 5
  }
})
</script>

<style scoped>
.skeleton-container {
  width: 100%;
}

.skeleton-card {
  background-color: var(--card-bg-color);
  border-radius: 8px;
  overflow: hidden;
}

.skeleton-table {
  width: 100%;
  border-collapse: collapse;
}

.skeleton-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--border-light-color);
}

.skeleton-header-row {
  display: flex;
  height: 48px;
  align-items: center;
}

.skeleton-row {
  display: flex;
  height: 60px;
  align-items: center;
  border-bottom: 1px solid var(--border-light-color);
}

.skeleton-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
  overflow: hidden;
}

.skeleton-tag {
  width: 30px;
  height: 20px;
  background-color: #e6e6e6;
  border-radius: 4px;
  animation: skeleton-loading 1.5s infinite;
}

.skeleton-image {
  width: 40px;
  height: 40px;
  background-color: #e6e6e6;
  border-radius: 4px;
  animation: skeleton-loading 1.5s infinite;
}

.skeleton-action-buttons {
  display: flex;
  gap: 8px;
}

.skeleton-button {
  width: 60px;
  height: 28px;
  background-color: #e6e6e6;
  border-radius: 4px;
  animation: skeleton-loading 1.5s infinite;
}

.skeleton-pagination {
  margin-top: 16px;
  padding: 0 20px;
}

.skeleton-pagination-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skeleton-pagination-info {
  width: 100px;
  height: 20px;
  background-color: #e6e6e6;
  border-radius: 4px;
  animation: skeleton-loading 1.5s infinite;
}

.skeleton-pagination-buttons {
  display: flex;
  gap: 8px;
}

.skeleton-pagination-button {
  width: 32px;
  height: 32px;
  background-color: #e6e6e6;
  border-radius: 4px;
  animation: skeleton-loading 1.5s infinite;
}

/* 骨架屏动画 */
@keyframes skeleton-loading {
  0% {
    background-color: rgba(200, 200, 200, 0.4);
  }
  50% {
    background-color: rgba(200, 200, 200, 0.8);
  }
  100% {
    background-color: rgba(200, 200, 200, 0.4);
  }
}

/* 伪元素实现骨架屏流动效果 */
.skeleton-tag::after,
.skeleton-image::after,
.skeleton-button::after,
.skeleton-pagination-info::after,
.skeleton-pagination-button::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 150%;
  }
}

/* 响应式调整 */
@media screen and (max-width: 768px) {
  .skeleton-table {
    overflow-x: auto;
  }
  
  .skeleton-header-row,
  .skeleton-row {
    min-width: 1200px;
  }
  
  .skeleton-pagination-content {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .skeleton-pagination-buttons {
    justify-content: center;
  }
}
</style>